<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>登录</title>
    <link rel="stylesheet" href="#(ctx)/assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="#(ctx)/assets/module/admin.css?v=314">
    <link rel="stylesheet" href="#(ctx)/assets/css/login.css?v=312">
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="login-wrapper">
    <div class="login-header">
        <img src="#(ctx)/assets/images/logo.png"> CESIUM场景管理
    </div>
    <div class=" login-body">
        <div class="layui-card">
            <div class="layui-card-header">
                <i class="layui-icon layui-icon-engine"></i>&nbsp;&nbsp;用户登录
            </div>
            <form class="layui-card-body layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
                    <div class="layui-input-block">
                        <input name="username" type="text" placeholder="账号" class="layui-input"
                               lay-verType="tips" lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
                    <div class="layui-input-block">
                        <input name="password" type="password" placeholder="密码" class="layui-input"
                               lay-verType="tips" lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <button lay-filter="login-submit" class="layui-btn layui-btn-fluid" lay-submit>登 录</button>
                </div>
            </form>
        </div>
    </div>
    <div class="login-footer">
        <p>© 2019 云南赢中科技集团有限公司 版权所有</p>
    </div>
</div>

<script type="text/javascript" src="#(ctx)/assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="#(ctx)/assets/js/jquery.min.js"></script>
<script type="text/javascript" src="#(ctx)/assets/js/jquery.base64.js"></script>
<script type="text/javascript" src="#(ctx)/assets/js/md5.js"></script>
<script type="text/javascript">
var base_server='#(base_server)';
</script>
<script>
    layui.config({
        base: '#(ctx)/assets/module/'
    }).use(['config', 'form'], function () {
        var $ = layui.jquery;
        var form = layui.form;
        var config = layui.config;
        config.putSerURL('#(ctx)');
        // 表单提交
        form.on('submit(login-submit)', function (data) {
            layer.load(2);
            $.ajax({
                url: '#(ctx)/doLogin',
                data: {
                	username:$.base64.encode(data.field.username),
                	password:$.base64.encode(hex_md5(data.field.password))
                	//password:$.base64.encode(data.field.password)
                },
                type: 'GET',
                dataType: 'JSON',
                success: function (res) {
                    if (res.code==200) {
                    	config.base_server='#(ctx)';
                    	config.putToken(res.data);
                        layer.msg('登录成功', {icon: 1, time: 1000}, function () {
                            location.replace('#(ctx)/index');
                        });
                    } else {
                        layer.closeAll('loading');
                        layer.msg(res.message, {icon: 5});
                    }
                },
                error: function (xhr) {
                    layer.closeAll('loading');
                    if (xhr.status == 400) {
                        layer.msg('账号或密码错误', {icon: 5});
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
</html>